package com.chx.three.mama.activities;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.chx.three.mama.R;
import com.chx.three.mama.view.Topbar;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ContentView;
import com.lidroid.xutils.view.annotation.ViewInject;

/**
 * 常见问题界面
 */
@ContentView(R.layout.activity_problem_help)
public class ProblemHelpActivity extends Activity implements Topbar.onTopbarClickListener {
    @ViewInject(R.id.problem_help_webview)
    WebView mWebView;
    @ViewInject(R.id.problem_topbar)
    Topbar topbar;

    ProgressDialog dialog = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        //设置去掉标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        ViewUtils.inject(this);

        topbar.setOnTopbarClickListener(this);


        Intent intent = getIntent();
        String url = intent.getStringExtra("url");

        mWebView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view,String url)
            {
                dialog.dismiss();
            }
        });

        mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
        mWebView.getSettings().setJavaScriptEnabled(true);

        mWebView.loadUrl(url);
        dialog = ProgressDialog.show(this, null, "页面加载中，请稍后..");

    }

    @Override
    public void onLeftButtonClick() {

    }

    @Override
    public void onRightButtonClick() {
        mWebView.reload();
        dialog = ProgressDialog.show(this,null,"页面加载中，请稍后..");
    }

    @Override
    public void onSearchButtonClick() {

    }
}
